	var orgId,orgName;
	var sysOrgTree,dealTreeNode;
	var bshowOrg = false;
	function onRename(){
		return false;
	}
	var Fstart = false;
	//拖拽
	function beforeDrag(treeId, treeNodes) {
		return false;
	}
	//展开所有
	function expandAll(){
		sysOrgTree.expandAll(true);
	}
	
	// 关闭所有
	function collapseAll(){
		sysOrgTree.expandAll(false);
	}
	//修改
	function beforeEditName(treeId, treeNode) {
	//	dealTreeNode = treeNode;
	//	updateSysOrgShow(treeNode.id);
	//	return true;
		return false;
	}
	function onRename(){
		return false;
	}
	//删除
	function beforeRemove(treeId, treeNode) {
	//	if(treeNode.isParent){
	//		alert('请先删除子组织');
	//		return false;
	//	}
	//	return delSysOrg(treeNode.id,treeNode.name);
		return false;
	}
	
	//展示删除按钮
	function showRemoveBtn(treeId, treeNode) {
		return false;
	}
	
	//展示修改按钮
	function showRenameBtn(treeId, treeNode) {
		return false;
	}
	
	//鼠标hover事件
	function addHoverDom(treeId, treeNode) {
	//	var sObj = $("#" + treeNode.tId + "_span");
	//	if (treeNode.editNameFlag || $("#addBtn_"+treeNode.tId).length>0) return;
	//	var addStr = "<span class='button add' id='addBtn_" + treeNode.tId
	//		+ "' title='add node' onfocus='this.blur();'></span>";
	//	sObj.after(addStr);
	//	var btn = $("#addBtn_"+treeNode.tId);
	//	// 点击添加按钮事件
	//	if (btn) btn.bind("click", function(){
	//		dealTreeNode = treeNode;
	//		addShow(treeNode.id);
	//		return false;
	//	});
	};
	
	//删除按钮
	function removeHoverDom(treeId, treeNode) {
		$("#addBtn_"+treeNode.tId).unbind().remove();
	};
	
	function showTree(){
		bshowOrg = false;
		$('#alertMessage').addClass('HdClass');
		$('#updateOrgBorder').addClass('HdClass');
		$('#rightDiv').removeClass('HdClass');
		$('#addRole').addClass('HdClass');
		$('#addRoleShow').addClass('HdClass');
		$('#orgForm').addClass('HdClass');
		$('#showOrgByIdBorder').addClass("HdClass");
		$('#TreeDiv').removeClass('HdClass');
		if(null==sysOrgTree){
			$.ajax({
				url:"../sysOrgController/loadOrgTreeData",
				data:{"pId":null},
				dataType : "json",
				type : "post",
				success : function(data){
					sysOrgTree = $.fn.zTree.init($("#tree"), setting, data);
				}
			})
		}

//		sysOrgTree.expandAll(false);
//		var rootNode = sysOrgTree.getNodes()[0];
//		sysOrgTree.expandNode(rootNode);
//		sysOrgTree.expandAll(false);//hhh
		
	}
	
	//刷新站点树
	function refreshTree(){
		$.post('../sysOrgController/refreshTree.action',{},function(data){
			sysOrgTree.destroy('tree');
			sysOrgTree = $.fn.zTree.init($("#tree"), setting, data);
//			sysOrgTree.expandAll(false);
			var rootNode = sysOrgTree.getNodes()[0];
			sysOrgTree.expandNode(rootNode);
			dealTreeNode = rootNode;
	
//			sysOrgTree.expandAll(false);//hhh
		});
	}
	// 基础设置
	var setting = {
		view: {
			addHoverDom: addHoverDom,
			removeHoverDom: removeHoverDom,
			selectedMulti: false
		},
		edit: {
			enable: false,
			editNameSelectAll: false,
			showRemoveBtn: showRemoveBtn,
			showRenameBtn: showRenameBtn
		},
		data: {
			simpleData: {
				enable: true
			}
		},
		async:{
			enable: true,
			url:"../sysOrgController/loadOrgTreeData",
			autoParam:["id=pid"]
		},
		callback: {
			beforeDrag: beforeDrag,
			beforeEditName: beforeEditName,
			beforeRemove: beforeRemove,
			onRename: onRename,
			beforeClick: function(treeId, treeNode) {
				
				$('#orgForm').removeClass('HdClass');
				$('#orgMessageBorder').removeClass('HdClass');
				$('#updateOrgBorder').addClass('HdClass');
				var treeId = treeId;
				orgName = treeNode.name;
				orgId = treeNode.id;
				afterClickTree(orgName);
			}
		}
	};
	//点击Tree之后触发的事件
	function afterClickTree(name){
		
		$('#TreeDiv').addClass('HdClass');
		$('#orgMessageBorder').removeClass('HdClass');
		$('#orgName').val(name);
		$('#sBtn').removeClass('HdClass');
		$('#orgId').val(orgId);
		//$('#orgName2').val(orgName);
		//alert();
	}
	
	$(function (){
		/*var total = document.documentElement.clientHeight;
		var colHeight = document.getElementById("leftDiv").offset().top-100;
		document.getElementById("leftDiv").style.height=colHeight+"px";*/
		if(map.id != 'uName'){
			//展示主岗信息
			showStaffOrgM(map.id,map.name2);
		}else{
			$('#rightDiv').removeClass('HdClass');
			$('#alertMessage').removeClass('HdClass');
		}
	})
	
	var index2 = ['orgName2','orgType2','status2','hireDate2','effectStartDate2','effectEndDate2','dataPermissionType2'];
	//点击岗位后展示
	function showStaffOrgM(id,name){
		$('#alertMessage').addClass('HdClass');
		$('#updateOrgBorder').addClass('HdClass');
		$('#orgMessageBorder').addClass('HdClass');
		$('#TreeDiv').addClass('HdClass');
		$('#rightDiv').removeClass('HdClass');
		$('#orgForm').addClass('HdClass');
		$('#addRole').addClass('HdClass');
		showOSM(id,name);
		$('#showOrgByIdBorder').removeClass('HdClass');
		bshowOrg = true;
	}
	
	var orgShowId;//Sys_Staff_Org的主键id
	var upname2;
	var uporgT2;
	var upstat2;
	var upohd2;
	var upesd2;
	var upeed2;
	var uptype2;
	var staffIdToUpdate;//修改完查询人员岗位的id
	//展示岗位
	function showOSM(id,name){
		$.ajax({
			url:"selectStaffOrgByStaffId",
			data:{id:id},
			cache:false,
			dataType:"JSON",
			type:"POST",
			success:function(data){
				orgShowId = data.staffOrgId;
				staffIdToUpdate = data.staffId;
				var orgId2 = data.orgId;
				$('#staffIdToUpdate').val(staffIdToUpdate);
				$('#staffOrgId2').val(orgShowId);
				$('#orgId2').val(orgId2);
				var orgT2 = data.staffOrgType;
				var stat2 = data.staffOrgStatus;
				var ohd2 = data.attra;
				var esd2 = data.attrb;
				var eed2 = data.attrc;
				var type2 = data.dataPermissionType;
				upname2 = name;
				uporgT2 = orgT2;
				upstat2 = stat2;
				upohd2 = ohd2;
				upesd2 = esd2;
				upeed2 = eed2;
				uptype2 = type2;
				// 'M 本人、S 指定人 ，O 本组织，D 本组织及其下级组织，C 下级组织，R 指定组织，T 指定组织及其下级，H 指定组织下级，E，自定义。' -->
				if('M' == type2){
					type2 = '本人';
				}else if('S' == type2){
					type2 = '<a href="javascript:void(0)" onclick="getTreeView('+"'"+"S"+"'"+');">指定人</a>';
				}else if('O' == type2){
					type2 = '本组织';
				}else if('D' == type2){
					type2 = '本组织及其下级组织';
				}else if('C' == type2){
					type2 = '下级组织';
				}else if('R' == type2){
					type2 = '<a href="javascript:void(0)" onclick="getTreeView('+"'"+"R"+"'"+');">指定组织</a>';
				}else if('T' == type2){
					type2 = '<a href="javascript:void(0)" onclick="getTreeView('+"'"+"T"+"'"+');">指定组织及其下级</a>';
				}else if('H' == type2){
					type2 = '<a href="javascript:void(0)" onclick="getTreeView('+"'"+"H"+"'"+');">指定组织下级</a>';
				}else if('E' == type2){
					type2 = '自定义';
				}
				//岗位类型
				$("#orgTypeNow").val(orgT2);
				var indexO = [name,orgT2=='F'?'主岗':(orgT2=='J'?'借调':'兼职'),stat2=='1'?'有效':'无效',ohd2,esd2,eed2,type2];
				for(var i=0;i<index2.length;i++){
					
					//如选择是指定人或指定组织，则需以链接方式展现，并可查看选择项。
					if("dataPermissionType2" == index2[i] && ('S' == uptype2 || 'R' == uptype2 || 'T' == uptype2 || 'H' == uptype2)){
//						var ele = document.getElementById(index2[i]);
//						if(ele != null) ele.innerHTML = '';
//						var txt = document.createElement(indexO[i]);
//						ele.innerHTML = indexO[i];
						continue;
					}else{
						var ele = document.getElementById(index2[i]);
						if(ele != null) ele.innerHTML = '';
						var txt = document.createTextNode(indexO[i]);
						ele.appendChild(txt);
					}
				}
				$('#addRoleShow').removeClass('HdClass');
				selectRoleWithOrg(orgShowId,orgId2);
			},
			error:function(XMLHttpRequest, textStatus, errorThrown){
				alertModel("出现异常，请联系管理员："+errorThrown);
			}
		});
	}
	
	//查看岗位信息时查看数据权限树
	function getTreeView(valueType){
		
		//获取岗位ID
		var staffId = $("#staffOrgId2").val();
		
		//此三种状态显示组织树
		if("R" == valueType || "T" == valueType || "H" == valueType){
			//调用模态框
			$("#showOrgTree").click();
			//数据权限树－－组织树
			showOrgTree();
			
			//得到tree对象
			var treeObj = $.fn.zTree.getZTreeObj("orgtree");
			//得到已保存的tree数据
			$.post('selecetSSOpermission.action',{'id':staffId,'flagStr':"so"},function(data){
				var so = data.so;
				if(so != null){
					for (var i=0; i < so.length; i++) {
						treeObj.checkNode(treeObj.getNodeByParam("id",so[i]), true);
					}
				}
			});
		}else if("S" == valueType){
			//调用模态框
			$("#showUser").click();
			//数据权限树－－岗位树
			userMessageSelect();
			
			//得到tree对象
			var treeObj = $.fn.zTree.getZTreeObj("stafforgtree");
			//得到已保存的tree数据
			$.post('selecetSSOpermission.action',{'id':staffId,'flagStr':"sso"},function(data){
				var sso = data.sso;
				if(sso != null){
					for (var i=0; i < sso.length; i++) {
						treeObj.checkNode(treeObj.getNodeByParam("id",sso[i]), true);
					}
				}
			});
		}
	}

	//展示角色
	function selectRoleWithOrg(id,orgId2){
		$.ajax({
			url:"selectRoleWithOrg.action",
			data:{staffOrgId:id,orgId:orgId2},
			dataType:"JSON",
			type:"POST",
			success:function(data){
				//岗位对应已有角色
				var list = data.list;
				//所有角色
				var list2 = data.list2;
				var div = "";
				var staffOrgIdajax = data.staffOrgId;
				if(list.length>0){
					div += "<div class='roleFontClass'>*&nbsp;&nbsp;勾选后请点击右下角的确认键</div>";
					$.each(list2,function(i,obj){
						var aboolean = false;
						
						$.each(list,function(j,obj2){
							//alert("i="+i+"--"+"j="+j);
							if(obj2.ID == obj.ID){
								aboolean = true;
							}
							//if(aboolean && j == (list.length-1)){
							//	div += "<label class='RoleCheckLabel'><span>"+obj.NAME+"</span><input type='checkbox' name='checkbox' value='"+obj.ID+"' style='margin:4px 4px 0;' checked='checked'/></label>";
							//}else if(!aboolean && j == (list.length-1)){
							//	div += "<label class='RoleCheckLabel'><span>"+obj.NAME+"</span><input type='checkbox' name='checkbox' value='"+obj.ID+"' style='margin:4px 4px 0;'/></label>";
							//}
						});
						
						if(true == aboolean){
							div += "<label class='RoleCheckLabel'><span>"+obj.NAME+"</span><input type='checkbox' name='checkbox' value='"+obj.ID+"' style='margin:4px 4px 0;' checked='checked'/></label>";
						}else{
							div += "<label class='RoleCheckLabel'><span>"+obj.NAME+"</span><input type='checkbox' name='checkbox' value='"+obj.ID+"' style='margin:4px 4px 0;'/></label>";
						}
						
					});
					if(hadPermission.update){
					div += "<div class='addRoleBtn'><button class='btn btn-primary' onclick='confirmUpdateRole(\""+staffOrgIdajax+"\",\""+orgId2+"\");'>确认修改角色</button></div>";
					}
				}else{
					if(hadPermission.add){
					div += "<button class='btn orgbtn btn-primary' onclick='showRole();'>添加角色</button>";
					}
				}
				document.getElementById('addRoleShow').innerHTML = "";
				document.getElementById('addRoleShow').innerHTML += div;
			},
			error:function(a,b,e){
				alertModel(e);
			}
		})
	}
	
	//查询所有角色
	function showRole(){
		//$('#addRoleShow').addClass('HdClass');
		
		var orgId2 = $("#orgId2").val();
		if(bshowOrg){
			//$('#addRoleShow').addClass('HdClass');
			$('#TreeDiv').addClass('HdClass');
			$('#addRole').addClass('HdClass');
			$('#addRole option').remove();
			$.ajax({
				url:"showAllRole.action",
				data:{orgId:orgId2},
				dataType:"JSON",
				type:"POST",
				success:function(data){
					if(data.length>0){
						var div = "";
						div += "<div class='roleFontClass'>*&nbsp;&nbsp;勾选后请点击右下角的确认键</div>";
						$.each(data,function(i,obj){
							div += "<label class='RoleCheckLabel'><span>"+obj.NAME+"</span><input type='checkbox' name='checkbox' value='"+obj.ID+"' style='margin:4px 4px 0;'></input></label>";
						});
						div += "<div class='addRoleBtn'><button class='btn btn-primary' onclick='comfirmAddRole();'>确认添加角色</button></div>";
						document.getElementById('addRoleShow').innerHTML = "";
						document.getElementById('addRoleShow').innerHTML += div;
					}else{
						alertModel("角色信息为空！");
					}
				},
				error:function(a,b,e){
					alertModel(e);
				}
			})
		}else{
			alertModel("请先选择岗位！");
			return false;
		}
		
	}

	//确认添加角色
	function comfirmAddRole(){
		confirmModel("确认添加角色吗？","addRole()");
	}
	function addRole(){
		//获取岗位所在组织的ID
		var orgId2 = $("#orgId2").val();
		var str = "";
		$("#addRoleShow label input:checked").each(function(){
			str += $(this).val()+",";
		})
		if(str.length > 0){
			var a = orgShowId;
			var value = $('#roleName').val();
			$('#addRole').addClass('HdClass');
			$('#addRoleShow').removeClass('HdClass');
			comfirmAddRoleAjax(a,str,orgId2);
		}else{
			$('#_frm_confirm_modal').modal('hide');
			alertModel("请勾选角色！");
		}
	}
	function comfirmAddRoleAjax(a,str,orgId){
		$.ajax({
		url:"addRole.action",
		data:"staffOrgId="+a+"&str="+str+"&orgId="+orgId,
		dataType:"JSON",
		type:"POST",
		success:function(data){
			$('#_frm_confirm_modal').modal('hide');
			if(data.da){
				//查询岗位对应角色
				var list = data.list;
				//所有角色
				var list2 = data.list2;
				//document.getElementById('addRole').innerHTML ="";
				var staffOrgIdajax = data.staffOrgId;
				var div = "";
				if(list.length>0){
					div += "<div class='roleFontClass'>*&nbsp;&nbsp;勾选后请点击右下角的确认键</div>";
					$.each(list2,function(i,obj){
						var aboolean = false;
						$.each(list,function(j,objj){
							if(obj.ID == objj.ID){
								aboolean = true;
							}
							if(aboolean && j == (list.length-1)){
								div += "<label class='RoleCheckLabel'><span>"+obj.NAME+"</span><input type='checkbox' name='checkbox' value='"+obj.ID+"' style='margin:4px 4px 0;' checked='checked'/></label>";
							}else if(!aboolean && j == (list.length-1)){
								div += "<label class='RoleCheckLabel'><span>"+obj.NAME+"</span><input type='checkbox' name='checkbox' value='"+obj.ID+"' style='margin:4px 4px 0;'></input></label>";
							}
						});
					});
					if(hadPermission.update){
					div += "<div class='addRoleBtn'><button class='btn btn-primary' onclick='confirmUpdateRole(\""+staffOrgIdajax+"\",\""+orgId+"\");'>确认修改角色</button></div>";
					}
					alertModel("添加角色成功！");
				}
				document.getElementById('addRoleShow').innerHTML = "";
				document.getElementById('addRoleShow').innerHTML += div;
			}else{
				alertModel("添加角色失败！");
			}
		},
		error:function(a,b,e){
			$('#_frm_confirm_modal').modal('hide');
			alertModel("添加角色失败！"+e);
		}
	});
	}

	//修改角色信息  orgId为组织ID
	function confirmUpdateRole(staffOrgId, orgId){
		confirmModel("确认修改角色信息吗？", "updateRole('" + staffOrgId + "','" + orgId + "')");
	}
	function updateRole(staffOrgId, orgId){
		var str = "";
		$("#addRoleShow label input:checked").each(function(){
			str += $(this).val()+",";
		})
		$.ajax({
			url:"deleteRoleByStaffOrgId.action",
			data:{staffOrgId:staffOrgId,orgId:orgId,str:str},
			dataType:"JSON",
			type:"POST",
			success:function(data){
				$('#_frm_confirm_modal').modal('hide');
				var result = data.result;
				if(result){
					//存在的角色
					var listExist = data.listExist;
					//所有的角色
					var div = "";
					if(listExist.length > 0){
						var staffOrgIdajax = data.staffOrgIdajax;
						var listAll = data.listAll;
						var div = "<div class='roleFontClass'>*&nbsp;&nbsp;勾选后请点击右下角的确认键</div>";
						$.each(listAll,function(i,obi){
							var aboolean = false;
							$.each(listExist,function(j,obj){
								if(obi.ID == obj.ID){
									aboolean = true;
								}
								if(aboolean && (j == listExist.length-1)){
									div += "<label class='RoleCheckLabel'><span>"+obi.NAME+"</span><input type='checkbox' name='checkbox' value='"+obi.ID+"' style='margin:4px 4px 0;' checked='checked'></input></label>";
								}else if(!aboolean && (j == listExist.length-1)){
									div += "<label class='RoleCheckLabel'><span>"+obi.NAME+"</span><input type='checkbox' name='checkbox' value='"+obi.ID+"' style='margin:4px 4px 0;'></input></label>";
								}
							});
						});
						if(hadPermission.update){
						div += "<div class='addRoleBtn'><button class='btn btn-primary' onclick='confirmUpdateRole(\""+staffOrgIdajax+"\",\""+orgId+"\");'>确认修改角色</button></div>";
						}
					}else{
						if(hadPermission.add){
						div += "<button class='btn orgbtn btn-primary' onclick='showRole();'>添加角色</button>";
						}
					}
					document.getElementById('addRoleShow').innerHTML = "";
					document.getElementById('addRoleShow').innerHTML += div;
					alertModel("修改角色成功！");
				}else{
					alertModel("修改角色失败！");
				}
			},
			error:function(a,b,e){
				$('#_frm_confirm_modal').modal('hide');
				alertModel("修改角色信息异常："+e);
			}
		})
	}
	
	//添加岗位提交......
	function subminOrgMessage(){
		confirmModel("确认新增岗位？","doSubmitOrg()");
	}
	function doSubmitOrg(){
		var orgType = $('#orgType').val();
		var staffId = $('#staffId').val();
		//岗位名称
		var newOrgName = $('#orgName').val();
		$.ajax({
			url:"checkOrgF.action",
			data:{staffId:staffId,
				newOrgName:newOrgName},
			dataType:"JSON",
			type:"POST",
			success:function(data){
				$('#_frm_confirm_modal').modal('hide');
				if(data.b2){
					alertModel("已经有相同名字的岗位了！");
				}else{
					if(data.b && orgType == 'F'){
						alertModel("已经存在主岗了！");
					}else{
						$('#orgForm').submit();
						$("input[type=reset]").trigger("click");
					}
				}
			},
			error:function(a,b,e){
				$('#_frm_confirm_modal').modal('hide');
				alertModel(e);
			}
		})
		
	}
		
	//确认修改
	function comfirmUpdate(){
		confirmModel("确认修改岗位？","doUpdate()");
	}
	function doUpdate(){
			var orgType = $('#orgType3').val();
			var staffId = $('#staffIdToUpdate').val();
			var staffOrgId2 = $('#staffOrgId2').val();
			$.ajax({
				url:"checkOrgF",
				data:{staffId:staffId,
					staffOrgId2:staffOrgId2},
				dataType:"JSON",
				type:"POST",
				success:function(data){
					$('#_frm_confirm_modal').modal('hide');
					if(data.b){
						if(data.b2){
							//把树中选择的数据放入修改的隐藏域中
							var treeOrgId = $('#treeOrgId').val();
							var treeStaffOrgId = $('#treeStaffOrgId').val();
							$('#treeOrgIdUpdate').val(treeOrgId);
							$('#treeStaffOrgIdUpdate').val(treeStaffOrgId);
							
							$('#updateOrgForm').submit();
							$('input[type=reset]').trigger("click");
						}else if(orgType == 'F'){
							alertModel("已经存在主岗了！");
						}else{
							//把树中选择的数据放入修改的隐藏域中
							var treeOrgId = $('#treeOrgId').val();
							var treeStaffOrgId = $('#treeStaffOrgId').val();
							$('#treeOrgIdUpdate').val(treeOrgId);
							$('#treeStaffOrgIdUpdate').val(treeStaffOrgId);
							
							$('#updateOrgForm').submit();
							$('input[type=reset]').trigger("click");
						}
					}else{
						//把树中选择的数据放入修改的隐藏域中
						var treeOrgId = $('#treeOrgId').val();
						var treeStaffOrgId = $('#treeStaffOrgId').val();
						$('#treeOrgIdUpdate').val(treeOrgId);
						$('#treeStaffOrgIdUpdate').val(treeStaffOrgId);
						
						$('#updateOrgForm').submit();
						$('input[type=reset]').trigger("click");
					}
				},
				error:function(a,b,e){
					$('#_frm_confirm_modal').modal('hide');
					alertModel(e);
				}
			})
			
		}
	//修改岗位
	function updateThisOrg(){
		bshowOrg = false;
		$('#showOrgByIdBorder').addClass('HdClass');
		$('#addRole').addClass('HdClass');
		$('#addRoleShow').addClass('HdClass');
		$('#updateOrgBorder').removeClass('HdClass');
		addOldData();
	}
	
	//加载旧数据
	//var upIndex = [orgShowId,upname2,uporgT2,upstat2,upohd2,upesd2,upeed2,uptype2];
	function addOldData(){
		$('#orgName3').val(upname2);
		$("#orgType3 option[value='"+uporgT2+"']").attr('selected','selected');
		if(upohd2 == '无'){
			$('#hireDate3').val('');
		}else{
			$('#hireDate3').val(upohd2);
		}
		if(upesd2 == '无'){
			$('#effectStartDate3').val('');
		}else{
			$('#effectStartDate3').val(upesd2);
		}
		if(upeed2 == '无'){
			$('#effectEndDate3').val("");
		}else{
			$('#effectEndDate3').val(upeed2);
		}

//		$("#dataPermissionType3").val(uptype2);
//		//$("#dataPermissionType3 option[value='"+uptype2+"']").removeAttr("selected");
//		
//		//根据选项确定是否显示查看按钮
//		if("S" == uptype2 || "R" == uptype2 || "T" == uptype2 || "H" == uptype2){
//			$("#getUpdateTreeSet").css("display","");
//		}else{
//			$("#getUpdateTreeSet").css("display","none");
//		}
	}
	
	//修改岗位时是否显示组织树或岗位树
	function updateDataPermissionType(value_){
		//根据选项确定是否显示查看按钮
		if("S" == value_ || "R" == value_ || "T" == value_ || "H" == value_){
			$("#getUpdateTreeSet").css("display","");
		}else{
			$("#getUpdateTreeSet").css("display","none");
		}
	}
	
	//修改时查看数据权限树
	function getUpdateTreeSet99(){
		
		var valueType = $("#dataPermissionType3").val();
		//获取岗位ID
		var staffId = $("#staffOrgId2").val();
		
		//此三种状态显示组织树
		if("R" == valueType || "T" == valueType || "H" == valueType){
			//调用模态框
			$("#showOrgTree").click();
			//数据权限树－－组织树
			showOrgTree();
			
			//得到tree对象
			var treeObj = $.fn.zTree.getZTreeObj("orgtree");
			//得到已保存的tree数据
			$.post('selecetSSOpermission.action',{'id':staffId,'flagStr':"so"},function(data){
				var so = data.so;
				if(so != null){
					for (var i=0; i < so.length; i++) {
						treeObj.checkNode(treeObj.getNodeByParam("id",so[i]), true);
					}
				}
			});
		}else if("S" == valueType){
			//调用模态框
			$("#showUser").click();
			//数据权限树－－岗位树
			userMessageSelect();
			
			//得到tree对象
			var treeObj = $.fn.zTree.getZTreeObj("stafforgtree");
			//得到已保存的tree数据
			$.post('selecetSSOpermission.action',{'id':staffId,'flagStr':"sso"},function(data){
				var sso = data.sso;
				if(sso != null){
					for (var i=0; i < sso.length; i++) {
						treeObj.checkNode(treeObj.getNodeByParam("id",sso[i]), true);
					}
				}
			});
		}
	}
	
	//删除岗位
	function deleteOrgBtn(){
		confirmModel("确定删除岗位？","doDeleteStaffOrg()");
	}
	function doDeleteStaffOrg(){
		//人员ID
		var staffId = $("#staffId").val();
		//岗位类型
		var orgTypeNow = $("#orgTypeNow").val();
		var id = orgShowId;
		$.ajax({
			url:"updateSetStatusById.action",
			data:{id:id,staffId:staffId,orgTypeNow:orgTypeNow},
			dataType:"JSON",
			type:"POST",
			success:function(data){
				$('#_frm_confirm_modal').modal('hide');
				if(data.result){
					//重新提交，然后跳转回来，把已删除的岗位去掉
					var name = $("#addOrgName").val();
					var id =  $("#staffId").val();
					var n2 = encodeURI(encodeURI(name));
					window.location.href = "goSysOrgAndRoleShow.action?id="+id;
					//showStaffOrgM(id,upname2);
				}else{
					alertModel("删除岗位失败！");
				}
			},
			error:function(a,b,e){
				$('#_frm_confirm_modal').modal('hide');
				alertModel("删除岗位时异常"+e);
			}
		});
	}
	
	function addStaffOrg(){
		var orgType = $('#orgType').val();
		var hireDate = $('#hireDate').val();
		var effectStartDate = $('#effectStartDate').val();
		var effectEndDate = $('#effectEndDate').val();
		var dataPermissionType = $("#dataPermissionType").val();
		window.loaction=("sysStaffController/addStaffOrg.action?orgId="+orgId);
		//window.location.href +"&orgName="+orgName+"&orgType="+orgType+"&hireDate="+hireDate+"&effectStartDate="+effectStartDate+"&effectEndDate="+effectEndDate+"&dataPermissionType="+dataPermissionType;
		//addOrg(orgType,hireDate,effectStartDate,effectEndDate,dataPermissionType);
	}
	
	//数据权限设置
	function staffOrgRoleSet(value_){
		//指定人
		if('S' == value_){
			$("#showUser").click();
			//隐藏查看按钮
			$("#getTreeSet100").css("display","");
			userMessageSelect();
		}else if('R' == value_ || 'T' == value_ || 'H' == value_){ //指定组织
			showOrgTree();
			$("#showOrgTree").click();
			//显示查看按钮
			$("#getTreeSet100").css("display","");
			//$("#orgTreeModal").modal(options);
			
		}
	}
	
	//数据权限－－岗位树
	function userMessageSelect(){
		chkboxFather="";
		chkboxChild="";
		//设置树的参数
		settingTreeFunction(chkboxFather,chkboxChild);
		bshowOrg = false;
		$('#roleModal').removeClass('HdClass');
		sysOrgTree = $.fn.zTree.init($("#stafforgtree"), settingTree, staffOrgTreeArrayNodes);
//		sysOrgTree.expandAll(false);
		var rootNode = sysOrgTree.getNodes()[0];
		sysOrgTree.expandNode(rootNode);
//		sysOrgTree.expandAll(false);   //hhh
	}
	
	//刷新数据权限组织树
	function refreshTreeOrg(){
		chkboxFather="";
		chkboxChild="";
		//设置树的参数
		settingTreeFunction(chkboxFather,chkboxChild);
		$.post('../sysOrgController/refreshTree.action',{},function(data){
			sysOrgTree.destroy('tree');
			sysOrgTree = $.fn.zTree.init($("#orgtree"), settingTree, data);
//			sysOrgTree.expandAll(false);
			var rootNode = sysOrgTree.getNodes()[0];
			sysOrgTree.expandNode(rootNode);
			dealTreeNode = rootNode;	
//			sysOrgTree.expandAll(false); //hhh
		});
	}
	
	//刷新数据权限岗位树
	function refreshTreeStaffOrg(){
		chkboxFather="";
		chkboxChild="";
		//设置树的参数
		settingTreeFunction(chkboxFather,chkboxChild);
		$.post('../sysOrgController/searchSysStaffOrgForTree.action',{},function(data){
			sysOrgTree.destroy('tree');
			sysOrgTree = $.fn.zTree.init($("#stafforgtree"), settingTree, data);
//			sysOrgTree.expandAll(false);
			var rootNode = sysOrgTree.getNodes()[0];
			sysOrgTree.expandNode(rootNode);
			dealTreeNode = rootNode;
//			sysOrgTree.expandAll(false);  //hhh
		});
	}
	
	
	//数据数据权限设置树
	var settingTree;
	
	//动态设置树的参数
	function settingTreeFunction(chkboxFather,chkboxChild){
		
		settingTree = {
				view: {
					addHoverDom: addHoverDom,
					removeHoverDom: removeHoverDom,
					selectedMulti: true	 //设置是否允许同时选中多个节点
				},
				edit: {
					enable: false, //设置 zTree 是否处于编辑状态
					editNameSelectAll: false, //节点编辑名称 input 初次显示时,设置 txt 内容是否为全选状态
					showRemoveBtn: showRemoveBtn, //设置是否显示删除按钮
					showRenameBtn: showRenameBtn //设置是否显示编辑名称按钮
				},
				data: {
					simpleData: {
						enable: true //确定 zTree 初始化时的节点数据、异步加载时的节点数据、或 addNodes 方法中输入的 newNodes 数据是否采用简单数据模式 (Array)
					}
				},
				check:{
					chkStyle:"checkbox",//勾选框类型
					enable:true, //设置 zTree 的节点上是否显示 checkbox
					chkboxType:{"Y":chkboxFather,"N":chkboxChild}
				},
				callback: {
					beforeDrag: beforeDrag,
					beforeEditName: beforeEditName,
					beforeRemove: beforeRemove,
					onRename: onRename,
					beforeClick: function(treeId, treeNode) {
						
						//$('#orgForm').removeClass('HdClass');
						//$('#orgMessageBorder').removeClass('HdClass');
						//$('#updateOrgBorder').addClass('HdClass');
						var treeId = treeId;
						orgName = treeNode.name;
						orgId = treeNode.id;
						afterClickTree(orgName);
					}
				}
			};
	}
	
	//数据权限展示树--组织树
	function showOrgTree(){
		
		chkboxFather="";
		chkboxChild="";
		//设置树的参数
		settingTreeFunction(chkboxFather,chkboxChild);
		
		bshowOrg = false;
		//$('#alertMessage').addClass('HdClass');
		//$('#updateOrgBorder').addClass('HdClass');
		//$('#rightDiv').removeClass('HdClass');
		//$('#addRole').addClass('HdClass');
		//$('#addRoleShow').addClass('HdClass');
		//$('#orgForm').addClass('HdClass');
		//$('#showOrgByIdBorder').addClass("HdClass");
		//$('#TreeDiv22').removeClass('HdClass');
		$('#orgTreeModal').removeClass('HdClass');
		sysOrgTree = $.fn.zTree.init($("#orgtree"), settingTree, zNodes);
//		sysOrgTree.expandAll(false);
		var rootNode = sysOrgTree.getNodes()[0];
		sysOrgTree.expandNode(rootNode);
//		sysOrgTree.expandAll(false);//hhh
	}
	
	//数据权限－组织树上选中的组织ID
	function getTreeValue(){
		var treeObj2 = $.fn.zTree.getZTreeObj("orgtree");
		var nodes = treeObj2.getCheckedNodes(true);
		var str2 = '';
		for(var i = 0 ; i < nodes.length; i++){
			str2 += nodes[i].id;
			str2 += ",";	
		}
		if(0 == str2.length){
			alertModel('请选择指定的组织!');
			return;
		}else{
			//隐藏域赋值
			$("#treeOrgId").val(str2);
			//$("#showOrgTree").click();
		}
	}
	
	function getTreeSet(){
		var dataPermissionType = $("#dataPermissionType").val();
		if("S" == dataPermissionType){
			$("#showUser").click();
		}else if("R" == dataPermissionType){
			$("#showOrgTree").click();
		}
	}
	
	//获取树上选中的岗位ID
	function getStaffOrgTreeValue(){
		var treeObj2 = $.fn.zTree.getZTreeObj("stafforgtree");
		var nodes = treeObj2.getCheckedNodes(true);
		var str2 = '';
		for(var i = 0 ; i < nodes.length; i++){
			str2 += nodes[i].id;
			str2 += ",";	
		}
		if(0 == str2.length){
			alertModel('您未选中任务岗位!');
			return;
		}else{
			//隐藏域赋值
			$("#treeStaffOrgId").val(str2);
		}
	}
